using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using System.Data.Common;
using Husb.Data;
using Husb.DataUtil;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Caching;

using CentralOffice.MyTable.Data;

using SmsTable = CentralOffice.MyTable.Data.SmsDataSet.smsDataTable;
using SmsRow = CentralOffice.MyTable.Data.SmsDataSet.smsRow;

namespace CentralOffice.MyTable.DataAccess
{
    public class SmsAdapter : DataAccessAdapter<MyTable.Data.SmsDataSet, SmsTable, SmsRow>
    {
        public SmsAdapter()
        {
            this.TableName = "sms";
            DeleteStoredProc = "Sms_DeleteSms";

            GetAllStoredProc = "Sms_SelectSmsAll";
            InsertStoredProc = "Sms_InsertSms";
            UpdateStoredProc = "Sms_UpdateSms";
            FindStoredProc = "Sms_SelectSmsDynamic";
            GetByIdStoredProc = "Sms_SelectSms";
            GetPagedStoredProc = "Sms_SelectSmsPaged";
            GetRowCountStoredProc = "Sms_SelectSmsRowCount";
        }

        protected override void PopulateInsertParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "ToId", DbType.String, "ToId", DataRowVersion.Current);
            db.AddInParameter(cmd, "RemindFlag", DbType.String, "RemindFlag", DataRowVersion.Current);
            db.AddInParameter(cmd, "DeleteFlag", DbType.String, "DeleteFlag", DataRowVersion.Current);
            db.AddInParameter(cmd, "BodyId", DbType.Int32, "BodyId", DataRowVersion.Current);

            db.AddInParameter(cmd, "ToName", DbType.String, "ToName", DataRowVersion.Current);
        }

        protected override void PopulateUpdateParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "Id", DbType.Int32, "SmsId", System.Data.DataRowVersion.Current);
            PopulateInsertParameters(db, cmd);
        }
    }
}
